\f2\b0\i\ulnone\ql\fs24\fi0\li0\gray0\fc0\cf0\up0\dn0 NEXTSTEP In Focus
\i0 , Fall 1993 (Volume 3, Issue 4). \
Copyright
\f3 ª
\f2 1993 by NeXT Computer, Inc. All Rights Reserved.\
\
\fs16 \
\fs94 NFS Performance Tuning\
\fs16 \
\pard\tx7500\tx9520\fs28\fc0\cf0 Wayde Schroeder\
\fs16 \
\i\fs28 Tuning NFS to work efficiently can both increase the speed at which you access NFS-mounted files and decrease the load on your network. This article explains the NFS tuning parameters you can set and shows you how to optimize the performance of Ethernet adapters on Intel-based PCs.\
\fs16 \
\
\pard\f0\b\i0\fc0\cf0 \
\
\fs48 Overview\
\fs16 \
\pard\tx7500\tx9520\f2\b0\fs28\fc0\cf0 The Network File System (NFS) allows a local computer to access files on another computer, as if the files were on the local computer's disk. Because most home directories and applications reside on NFS-mounted file systems, improving NFS performance on a network can make a big difference in user productivity. \
\fs16 \
\fs28 This article explains how to tune two basic NFS operations. It also compares the performance of the three Ethernet adapters currently available for use with NEXTSTEP, and shows how to get the best performance from each.\
\fs16 \
\pard\f0\b\fc0\cf0 \
\
\
\fs48 NFS tuning parameters\
\fs16 \
\pard\tx7500\tx9520\f2\b0\fs28\fc0\cf0 You can tune two aspects of NFS operation: How an NFS server is mounted and how the client and server communicate. All tuning parameters must be specified by the initial mount command. \
\fs16 \
\fs28 The most important tuning parameters are
\b rsize
\b0 and
\b wsize
\b0 . They control the sizes of the NFS read and write buffers, and therefore directly affect how long reading and writing take. For some networks,
\b timeo
\b0 and
\b retrans
\b0 are also important. The other parameters give you finer control over how to initiate mounts, what to do if communication fails, and what information to cache.\
\fs16 \
\fs28 Here's how to tune both NFS mounting and client/server communication.\
\fs16 \
\f0\b \
\fs28 Mounting the server\
\fs16 \
\f2\b0\fs28 There are three ways to initiate an NFS mount: The client can request a mount when its host computer starts up, the client can request a mount automatically with the
\b autonfsmount
\b0 command when the remote file system is needed, or you can mount a remote file system by hand using the
\b mount
\b0 command. \
\fs16 \
\fs28 When and how to use each method are covered in detail in “Techniques for Using the Network File System” (
\i support bulletin 1
\i0 , Summer 1991), so I won't explain it all here. What's important for this article is the fact that you tune NFS mounting the same way, no matter which mount method you use.\
\fs16 \
\fs28 The mount tuning parameters affect how the communication between the NFS client and the server is initiated. To initiate a mount, the client sends a request to a server. The server checks the access rights of the directory that the client wants to mount and the access rights of the client itself. If the server's NetInfo
\f3\fs20\up6 î
\f2\fs28\up0 database shows that the client is allowed access, the server sends the client an NFS file handle, which points to the mounted directory. \
\fs16 \
\pard\fc0\cf0 \
\pard\tx7500\tx9520\i\fs24\fc0\cf0 Note: To find out more about NFS access rights, see the UNIX manual page on
\b exportfs
\b0 .\
\i0\fs28 \
\pard\tx7660\tx9660\f0\b\i\fs16\fc0\cf0 \
\fs24 Mounting options\
\fs16 \
\pard\tx7500\tx9520\f2\b0\i0\fs28\fc0\cf0 You tune the mounting process by setting how long the client waits for the server to reply and how many times the client retries. You can also specify whether the client should run the retry process in the background or foreground. Retrying in the background allows the client to run other tasks while waiting; retrying in the foreground causes it to just wait for a response. Foreground retries are only useful if the client can't operate without the mount. \
\pard\tx7500\tx9520\f2\b0\i0\fs28\fc0\cf0 Normally you should specify the
\b bg
\b0 option, so your system can retry mount requests in the background. Use the
\b fg
\b0 option if the mount provides applications or data that the client needs to operate. \
\fs16 \
\fs28 The default values for
\b mnttimeo
\b0 and
\b retry
\b0 are normally fine. If the client accesses the server across a slow line—like a 56K-baud line or SLIP connection—or is overloaded, you can increase
\b mnttimeo
\b0 or
\b retry
\b0 to give the client a better chance of succeeding. Waiting longer for the server to respond doesn't cause big problems if the mount request is in the background. However, don't set these values higher than about 60 seconds—if the server doesn't respond in that time it's probably down and the client may as well give up the request. \
\fs16 \
\f0\b \
\fs28 NFS client/server communication\
\fs16 \
\f2\b0\fs28 Once a directory is mounted, a different set of parameters takes effect. They determine how the client and server communicate. The parameters you can set are listed in Figure 3.\
\b0 Determines how long the client waits after making an NFS request before retransmitting the request. If there is no response after this time, the client multiplies
\b timeo
\b0 by 2, waits that long, and retransmits. Default is 7 tenths of a second.\
\b0 Determines how many times the client retransmits a request before a soft mount reports an error and gives up, or a hard mount reports an error and continues trying. Default is 3 times.\
\b0 Determines whether the server can both read and write (
\b rw
\b0 ) or read-only (
\b ro
\b0 ). Home directories and source code servers should be read-write so users can save their updates. LocalApps servers can be mounted read-only. Default is
\fs28 You set these parameters the same way you set the mount parameters. For example, Figure 2 also shows how to set communication parameters with NFS Manager.\
\fs16 \
\pard\tx7660\tx9660\f0\b\i\fc0\cf0 \
\fs24 Reading and writing\
\fs16 \
\pard\tx7500\tx9520\f2\b0\i0\fs28\fc0\cf0 The most important parameters are
\b rsize
\b0 and
\b wsize
\b0 . Set them to the largest sizes your network can handle with a minimum number of time-outs. Don't bother setting them higher than 8192—there's no added benefit.\
\fs16 \
\pard\tx7660\tx9660\f0\b\i\fc0\cf0 \
\fs24 Timing out and retrying\
\fs16 \
\pard\tx7500\tx9520\f2\b0\i0\fs28\fc0\cf0 Set
\b timeo
\b0 to maximize efficiency when the server doesn't respond to a request. Setting it too high causes the client to wait too long to retransmit when a server drops a request, and therefore increases access times. Setting it too low may cause the client to retransmit when the server didn't drop a request but was just slow to respond. These unnecessary retransmit requests increase network traffic and slow things down even more. \
\fs16 \
\fs28 Setting
\b retrans
\b0 can stop a client from hanging when a server of a read-only, soft-mounted partition fails. For hard mounts this parameter only determines when an “NFS server \
\i server_name
\i0 not responding, still trying” message will be displayed. You don't normally need to change this parameter. \
\fs16 \
\
\pard\tx7660\tx9660\f0\b\i\fs24\fc0\cf0 Soft and hard mounts\
\fs16 \
\pard\tx7500\tx9520\f2\b0\i0\fs28\fc0\cf0 Always use the
\b hard
\b0 parameter with read-write mounts. A server must be stateless, which means it has to be able to restart at any time. When it comes back up, it reestablishes communication with its clients, and continues where it left off. When a client writes to a server, the server always sends a reply saying that the data has been written to a non-volatile media, like a hard disk, so the client knows exactly which data was received successfully. Using the
\b hard
\b0 setting ensures that the client of a failed server keeps trying until the server comes back up. After a server reestablishes communication, the client can continue where it left off with no data corruption. \
\fs16 \
\fs28 In contrast, if a server is mounted read-write with the
\b soft
\b0 parameter and the server goes down while a client is writing data, the client can give up without finishing the write operation. This leaves the server with incomplete, corrupted data. \
\fs16 \
\pard\tx7660\tx9660\f0\b\i\fc0\cf0 \
\fs24 Attribute caching\
\fs16 \
\pard\tx7500\tx9520\f2\b0\i0\fs28\fc0\cf0 You can use the parameters
\b acregmin
\b0 ,
\b acregmax
\b0 ,
\b acdirmin
\b0 ,
\b acdirmax
\b0 , and
\b noac
\b0 to cache attributes of files and directories. The minimum and maximum parameters control whether the client caches directory entries about files and subdirectories, and how long information stays in the cache. Caching this data reduces the number of messages sent across the network. In addition, the mapped file system (MFS) interacts with NFS—if NFS is caching a file's attributes, MFS tries to keep pages of that file in memory as well. This improves performance further.\
\fs16 \
\fs28 You may notice the effects of read caching if you compile source code from an NFS server: The first compile you run is relatively slow compared to later compilations. This is because the header files are read in from the server and information about them is cached on the client. Since these files don't normally change between compilations, the information about them is held in the client's cache indefinitely, until it's swapped out to make room for other information.\
\fs16 \
\fs28 A side effect of caching is that a client may not always have the most recent information about a file. For example, if a user on one client computer changes a file on a server, a user on another client computer may not detect the change until the client's attribute caching time expires. If you're using an application that needs to know immediately when a remote file changes, use the
\b noac
\b0 parameter to turn off caching.\
\fs16 \
\fs28 Another reason to set the
\b noac
\b0 parameter is testing. For example, one of the tests described later in this article times a read request from the server. The data is read ten times and the average time is measured. If attribute caching had been turned on, the file's information would have been read just once from the server and cached on the client. So the next nine read requests would have gotten data not from the server but from the client's cache, giving incorrect test results.\
\fs16 \
\pard\f0\b\fc0\cf0 \
\
\
\fs48 Tuning tests \
\fs16 \
\pard\tx7500\tx9520\f2\b0\fs28\fc0\cf0 Three Ethernet adapters are now supported for NEXTSTEP for Intel Processors: The 3Com EtherLink
\f3\fs20\up6 í
\f2\fs28\up0 III, SMC EtherCard PLUS Elite 16
\f3\fs20\up6 î
\f2\fs28\up0 , and Intel EtherExpress
\f3\fs20\up6 î
\f2\fs28\up0 . Each gives you a choice of external connector—BNC, AUI, or twisted pair. (Not all connectors are available on all adapters.) The type of external connection you use doesn't affect performance or tuning of NFS on the adapter, but each adapter has different levels of performance and must be tuned differently. \
\fs16 \
\fs28 I ran the adapters through two tests. The first was reading a one-megabyte file from an NFS server, with the Ethernet adapter in the client computer. The second test was writing a one-megabyte file to an NFS server, with the Ethernet adapter in the server. \
\fs16 \
\fs28 To perform the read or write I copied a file. I varied the values of the
\b rsize
\b0 ,
\b wsize
\b0 , and
\b timeo
\b0 parameters one at a time, measuring the time it took to read or write and the number of time-outs that occurred. I repeated each test ten times and took the average time as the result. The better performing adapter has shorter copy time and fewer timeouts. \
\fs16 \
\fs28 The PC I used was an ALR
\f3\fs20\up6 í
\f2\fs28\up0 Evolution IV
\f3\fs20\up6 î
\f2\fs28\up0 DX-2/166 EISA, with a Conner
\f3\fs20\up6 í
\f2\fs28\up0 1.3-gigabyte disk and a DPT
\f3\fs20\up6 í
\f2\fs28\up0 2022 SCSI controller with 4 megabytes of cache set for read and write caching. I used a 25-megahertz, 68040-based NeXTstation as the second system in all the tests. I also ran the tests between two 25-megahertz, 68040-based NeXTstation computers, to show the effects of changing the parameters for existing NeXT computers on a network.\
\fs16 \
\pard\f0\b\fc0\cf0 \
\
\
\fs48 3Com EtherLink III\
\fs16 \
\pard\tx7500\tx9520\f2\b0\fs28\fc0\cf0 This adapter has the smallest input buffer of the three: It's just two kilobytes. For this adapter, NFS read and write performance goes up and the number of time-outs drops dramatically when
\b rsize
\b0 and
\b wsize
\b0 are 1024 bytes. With larger values the buffer fills up and the adapter misses packets. Decreasing the values
\b
\b0 further decreases performance while reducing time-outs only slightly, and so isn't worthwhile.\
\b0 value affects speed only if a significant number of time-outs occur, as the next two graphs show. I plotted the results of changing it only for this adapter, because it didn't affect other adapters.\
\pard\tx7500\tx9520\i0\fs28\fc0\cf0 The large buffer means there are no time-outs, no matter how you set the tuning parameters. Performance drops as
\b rsize
\b0 and
\b wsize
\b0 decrease, so keep them as large a possible.\
\fs16 \
\pard\f0\b\fc0\cf0 \
\
\
\fs48 NeXTstation\
\fs16 \
\pard\tx7500\tx9520\f2\b0\fs28\fc0\cf0 The data for a NeXTstation provide relative data and highlight some problems you may have in mixed networks. In particular, the NeXTstations slow as
\b rsize
\b0 and
\b wsize
\b0 decrease. If you're using NeXTstations as NFS servers and have 3Com EtherLink III adapters on the same network—or to a lesser extent, SMC EtherCard PLUS Elite 16 adapters—changing
\pard\tx7500\tx9520\i0\fs28\fc0\cf0 Decreasing the buffer size to 1024 significantly reduces the performance of NeXTstations. Reducing
\b timeo
\b0 can increase the speed of the 3Com adapter when setting
\b rsize
\b0 and
\b wsize
\b0 to 8192, which keeps the performance of the NeXTstations at its best. However, you will still have many time-outs—and therefore retransmissions—on your network. This will increase the network traffic and slow things down as network load goes up, and isn't the best solution.\
\fs16 \
\fs28 A better choice is to set
\b rsize
\b0 and
\b wsize
\b0 to 1024 for the computers using 3Com adapters. This reduces the number of time-outs and retransmissions on the network. The optimal but not necessarily most practical thing to do is to put the different hardware in different NetInfo domains, so you can use different NFS mount parameters. \
\fs16 \
\f0\b \
\fs28 Result summary\
\fs16 \
\f2\b0\fs28 For PC networking, the Intel EtherExpress adapter provides the best performance of the three currently compatible adapters, so it's the best choice for performance. \
\fs16 \
\fs28 If you must use a different adapter, you can still tune NFS to get optimal performance. \
\pard\tx7500\tx9520\f2\b0\fs28\fc0\cf0 In most cases, tuning NFS performance can make a big difference in overall network performance, and thereby in system usability. To fine-tune your system, you can run tests like these. Be sure to turn off caching while testing, so you get accurate results.\
\fs16 \
\fs28 Your Ethernet media also affect how you tune NFS parameters. In future articles I'll cover tuning NFS across T1 lines, 56K-baud lines, routers, and SLIP connections.
\fs20 n\
\
\fs16 \
\i\fs24 Wayde Schroeder is a Premium Support Engineer. He's been at NeXT for three years. You can reach him by e-mail at